/*
 * llist.h
 *  双向链表处理库
 *  Created on: 2025年4月29日
 *      Author: ThinkPad
 */

#ifndef _LLIST_H__
#define _LLIST_H__

#define FORWARD     1
#define BACKWARD    2

typedef int list_cmp(void *key, void *data);
typedef void list_op(void *data);

struct llist_node_st
{
    void *data;
    struct llist_node_st *next;
    struct llist_node_st *prev;
};

typedef struct {
    int size;
    struct llist_node_st head;
} LLIST;

LLIST *ListCreage(int size);
int ListInsert(LLIST *list, void *data, int mode);
int ListDelete(LLIST *list, void *key, list_cmp *cmp);
void *ListFind(LLIST *list, void *key, list_cmp *cmp);
void ListTravel(LLIST *list, list_op *);
void ListDestory(LLIST *list);

#endif